<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" 
	xmlns:h="http://java.sun.com/jsf/html" 
	xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets" 
    xmlns:a4j="http://richfaces.org/a4j" 
    xmlns:rich="http://richfaces.org/rich"
    xmlns:p="http://primefaces.org/ui"
    xmlns:c="http://java.sun.com/jsp/jstl/core">
    <ui:composition>
		<h:head>
	    	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
			<title>Cristina Bittencourt Atelier</title>
			<meta name="keywords" content="wedding store, free web templates, free css templates" />
			<meta name="description" content="Wedding Store is a free web template for everyone. Download this template from templatemo.com" />
			<link rel="stylesheet" href="css/templatemo_style.css" type="text/css" />
			<script language="javascript" type="text/javascript">
			function clearText(field)
			{
			    if (field.defaultValue == field.value) field.value = '';
			    else if (field.value == '') field.value = field.defaultValue;
			}
			//Redireciona para o carrinho de compras
			function carrinho() {
		            window.location.href='carrinho.jsf';
		  	} 
			</script>
	
		 </h:head>	
		<div id="templatemo_wrapper_outter">
		
			<div id="templatemo_wrapper_inner">
		    
			   	<div id="templatemo_header">
					<ui:include src="header.xhtml"></ui:include>    
			   	</div> <!-- end of templatemo_header -->
		    
			    <div id="templatemo_menu">
			    	<ui:include src="menutop.xhtml"></ui:include>
			    </div> <!-- end of templatemo_menu -->
			    
			    <div id="templatemo_content_wrapper">
			    
			    	<div id="templatemo_sidebar_wrapper">
			    
			            <div id="templatemo_sidebar_top"></div>
			            <div id="templatemo_sidebar">
			            	<ui:include src="menuesquerdo.xhtml"></ui:include>
			            </div>
			            <div id="templatemo_sidebar_bottom"></div>
			        
			        </div>
			    	
					<div id="templatemo_content">
						<h:panelGroup rendered="#{loginController.loggedIn == false}">
							<h:form>
						        <p:panel header="Login">  
							        <p:messages autoUpdate="true"/>  
							        <h:panelGrid columns="2">  
							            <h:outputText value="Email: " />  
							            <p:inputText style="width: 290px;" value="#{loginController.email}" required="true" 
							            	validatorMessage="O email não é válido." 
							            	requiredMessage="O email deve ser preenchido."/>  
							            <h:outputText value="Senha: " />  
							            <p:password value="#{loginController.senha}" 
							            	required="true" maxlength="20" minLength="6"
							            	requiredMessage="A senha deve ser preenchida."
							            	promptLabel="Informe sua senha" feedback="false"></p:password>		
							        </h:panelGrid>  
							    </p:panel>
							    <br />  
							   <p:commandButton action="#{loginController.login}" value="Entrar" ajax="false"></p:commandButton>
					        </h:form>
					        <h:form>
					       	 	<p:commandButton action="cadastro" value="Cadastrar-se agora" ajax="false"></p:commandButton>
					        </h:form>
						</h:panelGroup>
				      <h:panelGroup rendered="#{loginController.loggedIn}">
					      <h2>#{loginController.usuario.nome}</h2>
					      <p:tabView id="tabView">
							<p:tab id="tab1" title="Minhas Compras">
								<h:panelGrid columns="2" cellpadding="10">
									<h:outputText id="tab1Text"
										value="The story begins as Don Vito Corleone, the head of a New York Mafia family, oversees his daughter's wedding.
										His beloved son Michael has just come home from the war, but does not intend to become part of his father's business. T
										hrough Michael's life the nature of the family business becomes clear. The business of the family is just like the head of the family, kind and benevolent to those who give respect,
										but given to ruthless violence whenever anything stands against the good of the family." />
								</h:panelGrid>
							</p:tab>
						
							<p:tab id="tab3" title="Dados Pessoais">
								<h:panelGrid columns="2" cellpadding="10">
									<h:form>
								        <p:messages autoUpdate="true"/>  
							        <h:panelGrid columns="2">  
							            <h:outputText value="Nome: " />  
							            <p:inputText value="#{usuarioController.usuario.nome}" 
							            	style="width: 250px;" required="true"
							            	requiredMessage="O nome deve ser preenchido."
							            	/>  
							  
							            <h:outputText value="Email: " />  
							            <p:inputText style="width: 290px;" value="#{usuarioController.usuario.email}" required="true" 
							            	validatorMessage="O email não é válido." 
							            	requiredMessage="O email deve ser preenchido."/>  
							            <h:outputText value="Data de Nascimento: " />  
							            <p:calendar value="#{usuarioController.usuario.datanascimento}" required="true" 
							            	validatorMessage="A data de nascimento não é válida" 
							            	requiredMessage="A data de nascimento deve ser preenchida."/>  	
							            
										<h:outputText value="CPF: " />  
							            <p:inputText value="#{usuarioController.usuario.cpf_cnpj}" 
							            	style="width: 200px;" required="true"
							            	requiredMessage="O CPF deve ser preenchido."
							            	/>  
							            <h:outputText value="Telefone: " />  
										<h:panelGroup>
											<p:inputText style="width:40px" value="#{usuarioController.usuario.codigoArea}" required="true" 
								            	requiredMessage="O código de área deve ser preenchido." maxlength="2"/> 
								            <p:spacer width="3"></p:spacer>
								            <p:inputText style="width:149px;" value="#{usuarioController.usuario.telefone}" required="true" 
								            	requiredMessage="O telefone deve ser preenchido." maxlength="8"/>  		
										</h:panelGroup>	
							            <h:outputText value="Estado: " />  	
							            <h:selectOneMenu id="estado" value="#{usuarioController.selectedEstado}">
											 <f:selectItem  itemValue="" itemLabel="Selecione..."/>
											 <f:selectItems value="#{usuarioController.listarEstados}" 
											 	var="item" itemLabel="#{item.nome}" itemValue="#{item.id}"/>
											  <p:ajax update="cidade" />  	
										</h:selectOneMenu>
										<h:outputText value="Cidade: " />  	
							            <h:selectOneMenu id="cidade" value="#{usuarioController.idCidade}">
											 <f:selectItem itemValue="" itemLabel="Selecione..." />
											 <f:selectItems value="#{usuarioController.listarCidades}" 
											 	var="item" itemLabel="#{item.nome}" itemValue="#{item.id}"/>
										</h:selectOneMenu>	
										<h:outputText value="CEP: " />  
							            <p:inputText value="#{usuarioController.usuario.codigoPostal}" 
							            	style="width: 250px;" required="true"
							            	requiredMessage="O CEP deve ser preenchido."
							            	/> 
							            <h:outputText value="Rua: " />  
							            <p:inputText value="#{usuarioController.usuario.rua}" 
							            	style="width: 250px;" required="true"
							            	requiredMessage="A rua deve ser preenchida."
							            	/> 	
							            <h:outputText value="Número: " />  
							            <p:inputText value="#{usuarioController.usuario.numero}" 
							            	style="width: 100px;"/> 
							            <h:outputText value="Complemento: " />  
							            <p:inputText value="#{usuarioController.usuario.complemento}" 
							            	style="width: 250px;"/> 		
							            <h:outputText value="Senha: " />  
							            <p:password id="senha1"
							            	required="true" maxlength="20" minLength="6"
							            	feedback="true" goodLabel="Normal" strongLabel="Forte" weakLabel="Fraco" 
							            	requiredMessage="A senha deve ser preenchida."
							            	validatorMessage="Confirmação de senha inválida."
							            	promptLabel="Informe sua senha"
							            	match="senha2"
							            	></p:password>
							            <h:outputText value="Confirmação de Senha: " />  
							            <p:password id="senha2" value="#{usuarioController.usuario.senha}" 
							            	required="true" maxlength="20" minLength="6"
							            	feedback="true" goodLabel="Normal" strongLabel="Forte" weakLabel="Fraco" 
							            	requiredMessage="A confirmação de senha deve ser preenchida."
							            	promptLabel="Informe sua senha"></p:password>		
							            	
							        </h:panelGrid>  
								    <br />  
								   <p:commandButton 
								   action="#{usuarioController.alterarUsuario}" value="Atualizar" ajax="false"></p:commandButton>
						        </h:form>
								</h:panelGrid>
							</p:tab>
						
						</p:tabView>
								
				      </h:panelGroup>
				      
				    </div>
			        <div class="cleaner"></div>
			        
			    </div> <!-- end of templatemo_content_wrapper -->
			    
			    <div id="templatemo_footer">
					<ui:include src="footer.xhtml"></ui:include>
			    </div>
		    
		    </div> <!-- end of templatemo_wrapper_inner -->
		
		</div> <!-- end of templatemo_wrapper_outter -->
		
    </ui:composition>
</html>